<?php $sessionGetUser = $this -> session -> get('user'); ?>
<aside class="main-sidebar">
  <section class="sidebar">
    <div class="user-panel">
      <div class="pull-left image">
        <img src="/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
      </div>

      <div class="pull-left info">
        <p><?php echo $sessionGetUser['user_code']; ?></p>
        <a href="javascript:void(0);"><i class="fa fa-fw fa-circle text-success"></i> <?php echo $this -> config['user_level'][$sessionGetUser['user_level']]; ?></a>
      </div>
    </div>

    <ul class="sidebar-menu" data-widget="tree">
      <li class="header">网页导航</li>
      <?php
        $menus = $this -> config -> menus -> toArray();
        if($sessionGetUser['shop_level'] == 1) {
          $menus[2]['children'][2]['name'] = '开店';
          unset($menus[3]);
          $menus = array_merge($menus);
        }
      ?>
      <?php foreach($menus as $menu) { ?>
        <?php $currentURI = $this -> request -> getURI(); ?>
        <?php if($menu['is_child']) {?>
          <li class="<?php if(strpos($menu['hrefs'], $currentURI) !== false) { echo 'active'; } ?> treeview">
            <a href="javascript:void(0);">
              <i class="fa fa-fw <?php echo $menu['icon'] ?>"></i> <span><?php echo $menu['name'] ?></span>
              <span class="pull-right-container"><i class="fa fa-fw fa-angle-left pull-right"></i></span>
            </a>
            
            <ul class="treeview-menu">
              <?php foreach($menu['children'] as $cmenu) { ?>
              <li class="<?php if($currentURI == $cmenu['href']) { echo 'active'; } ?>"><a href="<?php echo $cmenu['href'] ?>"><i class="fa fa-fw fa-circle-o"></i> <?php echo $cmenu['name'] ?></a></li>
              <?php } ?>
            </ul>
          </li>
        <?php } else { ?>
          <li class="<?php if($currentURI == $menu['href']) { echo 'active'; } ?>"><a href="<?php echo $menu['href'] ?>"><i class="fa fa-fw <?php echo $menu['icon'] ?>"></i> <span><?php echo $menu['name'] ?></span></a></li>
        <?php } ?>
      <?php } ?>
    </ul>
  </section>
</aside>